<template>
  <bar :totalQuestions="items.length" />
  <div class="list-container">
      <div class="list-item" v-for="(item, index) in items" :key="index">
        <div class="item-content">
          <h2 class="item-title"> {{ item.chapter }} {{ item.name }}</h2>
        </div>
        <div class="item-time">
          {{item.st}}
        </div>
      </div>
  </div>
  <div class="homework-buttons">
    <button class="submit-button" @click="create">
      新建作业
    </button>
  </div>
  <div style="display: flex; justify-content: center;">
    <Sidebar />
  </div>
</template>

<script>
import Bar from './components/bar2.vue';
import Sidebar from '@/components/Sidebar.vue';
import router from '@/router'

export default {
    components: {
        Bar,
        Sidebar,
    },
    data() {
        return {
          items: [
            {
              name: '递归的概念',
              date: '2024.9.18',
              chapter: '2.1',
              st: '已发布'
            },
            {
              name: 'NP完全性理论',
              date: '2024.9.15',
              chapter: '1.3',
              st: '已发布'
            },
            {
              name: '算法复杂度分析',
              date: '2024.9.15',
              chapter: '1.2',
              st: '已发布'
            },
            {
              name: '算法与程序',
              date: '2024.9.15',
              chapter: '1.1',
              st: '已发布'
            }],
            selectedItems: [],
        }
    },
    methods: {
        create(){
          router.push('/new_homework')
        }
    }
}
</script>

<style scoped>

.list-container {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
}

.item-content {
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.item-date {
    font-size: 14px;
    color: #666;
}

.item-time {
    font-size: 16px;
    color: #666;
}

.homework-buttons {
  display: flex;
  justify-content: center;
  gap: 10%
}

.item-select {
    background-color: transparent;
    border: none;
    cursor: pointer;
}

.circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #ccc;
    display: inline-block;
    margin-right: 10px;
}

.selected {
    background-color: #41A2FF;
}

.submit-button {
    margin-top: 20px;
    background-color: #41A2FF;
    color: aliceblue;
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
</style>
